<template>
  <div class="home">
    <div class="header" @click="show">{{$t("title")}}</div>
    <div class="contain">
          <div class="aside">
      <div class="userinfo" v-if="!isCollapse">
        <div class="userimg"></div>
        <div class="username">{{nickName}}</div>
         <div class="leavebtn" @click="backlogin"></div>
      </div>
      <div class="routerlist">  
    <el-menu default-active="1" class="routelist" 
    :collapse="isCollapse"
     @select="chooseroute"
     v-if="adminID"
     >
  <el-submenu index="1" v-if="adminID==1||adminID==2" >
    <template slot="title">
      <i class="el-icon-s-home"></i>
      <span slot="title">{{$t("editor.sysmange")}}</span>
    </template>
      <el-menu-item index="edmange">
     <span slot="title">{{$t("editor.admange")}} </span>   
        </el-menu-item>
      <el-menu-item index="edreport">
      <span slot="title"> {{$t("editor.adreport")}}</span>
        </el-menu-item>
      <el-menu-item index="edrequest">
          <span slot="title"> {{$t("editor.adrequest")}}</span>
        </el-menu-item>
  </el-submenu>
    <el-submenu index="2" v-else >
    <template slot="title">
      <i class="el-icon-s-marketing"></i>
      <span slot="title">{{$t("admin.sysmange")}}</span>
    </template>
      <el-menu-item index="adcharge">{{$t("admin.coinscharge")}}</el-menu-item>
      <el-menu-item index="adrecoin">{{$t("admin.coinsrecord")}}</el-menu-item>
      <el-menu-item index="adrecord">{{$t("admin.adrecord")}}</el-menu-item>
      <el-menu-item index="adbuy">{{$t("admin.adbuy")}}</el-menu-item>
      <el-menu-item index="admanage">{{$t("admin.admanage")}}</el-menu-item>
  </el-submenu>
</el-menu>
      </div>
    
    </div>
    <div class="content">
      <router-view></router-view>
    </div>
    </div>
  </div>
</template>

<script>
import { EventBus } from "../Util/eventBus";
import { getAdminUser} from '../Util/request';

  export default {
   data() {
      return {
        isCollapse: false,
        adminID:"",
        nickName:'',
      };
    },
    created(){
       
          getAdminUser((res)=>{
          if(res.code==200){
            this.adminID=res.data.jurisdiction
            this.nickName =res.data.nickName
          }
        })
      


    },

    methods: {
      show(){
         console.log(this.$store.state.adminId)
      },
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      chooseroute(e){  
        console.log(this.$store.state.adminId)
          if(`/home/${e}`!==this.$route.path){
            this.$router.push(`/home/${e}`)
          }else{
            return
          }     
      },
      backlogin(){
        localStorage.setItem("token",null)
        this.$router.replace('/')
      }

      
    }
  };
</script>
<style lang="less" scoped>
.home{
  position: relative;
  width: 100%;
  height: 100%;
   overflow: hidden;
}
.header{
  width: 100%;
  height: 60px;
  background: #47d6eb;
  font-size: 30px;
  line-height: 60px;
  color: #fff;
  text-align: center;
}
.aside{
  flex: 2;
  position: relative; 
  width: 300px;
  height: 980px;
  background-color: #2f4051;
  .userinfo{
    position: relative;
    width: 100%;
    height: 100px;
    background: #fff;
    overflow: hidden;
    .userimg{
      width: 70px;
      height: 70px;
      background-color: #000;
      border-radius: 50%;
      margin-top: 15px;
      margin-left: 30px;
    
    }
    .username{
      position: absolute;
      top: 16px;    
      left: 133px;
      width: auto;
      height: 30px;
      line-height: 30px;
      font-size: 20px; ;
    }
 .leavebtn{
       position: absolute;
       top: 43px;
       left: 150px;
       width: 40px;
       height: 40px;
       background: url(../assets/icons/退出.png)  no-repeat ;
       background-size: 100% 100%;
       cursor: pointer;
    }
  }
  .routelist{
  
  }
   

}
.contain{
  display: flex;
}
.content{
  flex:8;
  float: right;
  height: 980px;
  // background-color: red;
  overflow: scroll;
}
.content::-webkit-scrollbar{
  width: 0;
  height: 0;
}
</style>